package com.chatgpt.platformbasedchatgpt.controller;


import com.chatgpt.platformbasedchatgpt.dao.History;
import com.chatgpt.platformbasedchatgpt.service.HistoryService;
import com.chatgpt.platformbasedchatgpt.utils.CommonResult;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author Chat
 * @since 2023-12-03
 */
@RestController
public class HistoryController {
    @Autowired
    HistoryService historyService;

    @GetMapping("/getHistory/{userId}")
    public CommonResult getHistory(@PathVariable int userId){
        return  CommonResult.success(historyService.getHistory(userId));
    }

    @PostMapping("/saveHistory")
    public CommonResult saveHistory(@RequestBody History history){
        int i = historyService.saveHistory(history);
        if(i!=0){
           return CommonResult.success(null);
        }else return CommonResult.failed();
    }
}

